package com.ss.android.mine;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.bytedance.frameworks.baselib.network.http.util.TaskInfo;
import com.ss.android.account.activity.AuthorizeActivity;
import com.ss.android.account.b.OnAccountRefreshListener;
import com.ss.android.account.Spipe;
import com.ss.android.account.e.MuteQuickClickListener;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.c.ImageManager;
import com.ss.android.article.base.feature.feed.FeedTab;
import com.ss.android.article.base.ui.CircularImageView;
import com.ss.android.article.browser.R;
import com.ss.android.common.app.AbsFragment;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.image.AvatarLoader;
import com.ss.android.image.BaseImageManager;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import java.util.HashMap;

public final class ae extends AbsFragment implements OnAccountRefreshListener {
    private String A;
    private MuteQuickClickListener B;
    AppData mAppData;
    public RelativeLayout b;
    View c;
    EditText d;
    EditText e;
    private Spipe f;
    private IWXAPI g;
    private AvatarLoader h;
    private AvatarLoader i;
    private TaskInfo j;
    private Resources k;
    private Activity l;
    private View m;
    private LinearLayout n;
    private CircularImageView o;
    private TextView p;
    private View q;
    private ImageView r;
    private ImageView s;
    private ImageView t;
    private View u;
    private View v;
    private View w;
    private View x;
    private View y;
    private View z;

    public ae() {

        this.A = null;
        this.B = new aj(this);
    }

    private void a() {
        int v2 = 8;
        if(this.f != null && (this.isViewValid())) {
            if(this.f.isLogin) {
                UIUtils.setVisibility(this.n, 0);
                UIUtils.setVisibility(this.q, v2);
                this.h.loadAvatar(this.o, this.f.avatarUrl);
                this.p.setText(this.f.userName);
            }
            else {
                UIUtils.setVisibility(this.n, v2);
                UIUtils.setVisibility(this.q, 0);
            }
        }
    }

    final void a(String platform) {
        FragmentActivity fragmentActivity = this.getActivity();
        if(fragmentActivity != null) {
            this.A = platform;
            if("qzone_sns".equals(this.A)) {
                this.b("login_qzone");
            }
            else if("mobile".equals(this.A)) {
                this.b("login_mobile");
            }
            else if("weixin".equals(this.A)) {
                this.b("login_weixin");
            }

            if("mobile".equals(this.A)) {
                Bundle bundle = new Bundle();
                bundle.putString("extra_source", "mine_tab");
                com.ss.android.account.v2.aa.getInstance();
                com.ss.android.account.v2.aa.startAccountLoginActivity(((Context)fragmentActivity), bundle);
                return;
            }

            Intent intent = new Intent(fragmentActivity, AuthorizeActivity.class);
            intent.putExtra("platform", platform);
            fragmentActivity.startActivity(intent);
        }
    }

    final void b(String arg3) {
        MobClickCombiner.onEvent(this.getActivity(), "mine_tab", arg3);
    }

    public final void onAccountRefresh(boolean arg3, int arg4) {
        if(this.isViewValid()) {
            if(this.f.isLogin) {
                if("qzone_sns".equals(this.A)) {
                    this.b("login_qzone_success");
                }
                else if("qq_weibo".equals(this.A)) {
                    this.b("login_qq_success");
                }
                else if("sina_weibo".equals(this.A)) {
                    this.b("login_sina_success");
                }
                else if("weixin".equals(this.A)) {
                    this.b("login_weixin_success");
                }
            }

            this.A = null;
            this.a();
        }
    }

    public final void onActivityCreated(Bundle arg15) {
        int v13 = 8;
        int v12 = 1;
        int v5 = 0;
        super.onActivityCreated(arg15);
        this.l = this.getActivity();
        this.f = Spipe.inst();
        this.mAppData = AppData.getInstance();
        this.g = this.mAppData.l(this.getActivity());
        this.f.addOnAccountRefreshListener(this);
        this.j = new TaskInfo();
        ImageManager v3 = new ImageManager(this.l);
        this.k = this.l.getResources();
        new HashMap();
        this.h = new AvatarLoader(com.ss.android.article.browser.R.drawable.u3, this.j, ((BaseImageManager)v3), this.k.getDimensionPixelSize(R.dimen.gm), 0, false);
        int v10 = this.k.getDimensionPixelSize(R.dimen.gl);
        this.i = new AvatarLoader(com.ss.android.article.browser.R.drawable.u3, this.j, v3, v10, v10, true);
        this.h.d = new AvatarLoader.ProfileAvatarAnchor(this);
        DisplayMetrics v0 = new DisplayMetrics();
        this.l.getWindowManager().getDefaultDisplay().getMetrics(v0);
        TypedValue.applyDimension(1, 80f, v0);
        UIUtils.getScreenWidth(this.l);
        this.n.setOnClickListener(this.B);
        this.r.setOnClickListener(this.B);
        this.s.setOnClickListener(this.B);
        this.t.setOnClickListener(this.B);
        this.v.setOnClickListener(this.B);
        this.w.setOnClickListener(this.B);
        this.x.setOnClickListener(this.B);
        this.y.setOnClickListener(this.B);
        this.z.setOnClickListener(this.B);
        if(this.g == null || !this.g.isWXAppInstalled()) {
            v12 = 0;
        }

        ImageView v1 = this.s;
        int v0_1 = v12 != 0 ? 0 : v13;
        UIUtils.setVisibility(((View)v1), v0_1);
        View v0_2 = this.u;
        if(v12 == 0) {
            v5 = v13;
        }

        UIUtils.setVisibility(v0_2, v5);
    }

    public final void onActivityResult(int arg2, int arg3, Intent arg4) {
        super.onActivityResult(arg2, arg3, arg4);
        if(arg2 == 100 && arg3 == -1) {
            android.support.design.a.a(this.getActivity());
        }
    }

    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ComponentsManifest.findComponent(com.ss.android.account.v2.bb.class);
    }

    public final View onCreateView(LayoutInflater arg6, ViewGroup arg7, Bundle arg8) {
        View v1 = arg6.inflate(com.ss.android.article.browser.R.layout.fq, arg7, false);
        if(v1 != null) {
            this.m = v1.findViewById(com.ss.android.article.browser.R.id.a2o);
            this.b = v1.findViewById(com.ss.android.article.browser.R.id.a2p);
            this.o = v1.findViewById(com.ss.android.article.browser.R.id.user_avatar_iv);
            this.p = v1.findViewById(com.ss.android.article.browser.R.id.user_name_tv);
            this.n = v1.findViewById(com.ss.android.article.browser.R.id.usr_info_layout);
            this.q = v1.findViewById(com.ss.android.article.browser.R.id.a3f);
            this.r = v1.findViewById(com.ss.android.article.browser.R.id.a3h);
            this.s = v1.findViewById(com.ss.android.article.browser.R.id.a3i);
            this.t = v1.findViewById(com.ss.android.article.browser.R.id.iv_share_paltform_qzone);
            this.u = v1.findViewById(com.ss.android.article.browser.R.id.a3j);
            this.v = v1.findViewById(com.ss.android.article.browser.R.id.a2q);
            v1.findViewById(com.ss.android.article.browser.R.id.a2r);
            v1.findViewById(com.ss.android.article.browser.R.id.a2s);
            v1.findViewById(com.ss.android.article.browser.R.id.a2t);
            this.w = v1.findViewById(com.ss.android.article.browser.R.id.a2u);
            v1.findViewById(com.ss.android.article.browser.R.id.a2v);
            v1.findViewById(com.ss.android.article.browser.R.id.a2w);
            v1.findViewById(com.ss.android.article.browser.R.id.a2x);
            this.x = v1.findViewById(com.ss.android.article.browser.R.id.a2y);
            v1.findViewById(com.ss.android.article.browser.R.id.a2z);
            v1.findViewById(com.ss.android.article.browser.R.id.a30);
            v1.findViewById(com.ss.android.article.browser.R.id.a31);
            this.y = v1.findViewById(com.ss.android.article.browser.R.id.a32);
            v1.findViewById(com.ss.android.article.browser.R.id.a33);
            v1.findViewById(com.ss.android.article.browser.R.id.a34);
            v1.findViewById(com.ss.android.article.browser.R.id.a35);
            this.z = v1.findViewById(com.ss.android.article.browser.R.id.a36);
            v1.findViewById(com.ss.android.article.browser.R.id.a37);
            v1.findViewById(com.ss.android.article.browser.R.id.a38);
            v1.findViewById(com.ss.android.article.browser.R.id.a39);
            this.c = v1.findViewById(com.ss.android.article.browser.R.id.a3_);
            this.d = v1.findViewById(com.ss.android.article.browser.R.id.a3a);
            this.e = v1.findViewById(com.ss.android.article.browser.R.id.a3b);
        }

        if((this.getActivity() instanceof FeedTab)) {
            this.m.setPadding(0, ((int) UIUtils.dp2px(this.getContext(), 30f)), 0, 0);
        }

        if(android.support.design.a.isTest(this.getActivity())) {
            this.z.setOnLongClickListener(new af(this));
            this.d.addTextChangedListener(new ah(this));
            this.e.addTextChangedListener(new ai(this));
        }

        return v1;
    }

    public final void onDestroy() {
        super.onDestroy();
        if(this.h != null) {
            this.h.onDestroy();
        }

        if(this.i != null) {
            this.i.onDestroy();
        }

        if(this.j != null) {
            this.j.a = true;
        }

        if(this.f != null) {
            this.f.b(this);
        }
    }

    public final void onResume() {
        super.onResume();
        if(this.h != null) {
            this.h.onPause();
        }

        if(this.i != null) {
            this.i.onPause();
        }

        this.a();
    }

    public final void onStop() {
        super.onStop();
        if(this.h != null) {
            this.h.onStop();
        }

        if(this.i != null) {
            this.i.onStop();
        }
    }
}

